import { ComponentInfoType } from '@/store/componentsReducer'
import request from '../utils/request'

/**
 *  新建问卷
 */
export const createQuestionAPI = () => {
  return request<{
    id: string
  }>('/api/question', 'post')
}

/**
 *  获取单条问卷详情
 */
export const itemDetailsDataAPI = (id: string) => {
  return request<{
    id: string
    title: string
    componentList: ComponentInfoType[]
  }>(`/api/question/${id}`, 'get')
}

/**
 *  获取问卷列表
 */
export const questionListAPI = (params?: {
  search?: string
  isStar?: boolean
  isDeleted?: boolean
  page?: number
  pageSize?: number
}) => {
  return request<any>('/api/question', 'get', params)
}

/**
 *  修改问卷
 */
export const itemUpDateAPI = (id: string) => {
  return request<any>(`/api/question/${id}`, 'patch')
}
